package com.example.controller;

import com.example.pojo.Activity;
import com.example.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ActivityController {
    @Autowired
    private ActivityService activityService;


    @PostMapping("/add-Activity")
    public String saveActivity(@ModelAttribute("activity") Activity activity) {
        // 执行保存活动的逻辑
        activityService.add(activity);
        return "redirect:/activity";
    }

    @GetMapping("/seacher-activity")
    public String showActivityList(Model model,int id) {
        Activity activities = activityService.query(id);
        model.addAttribute("activities", activities);
        return "activity";
    }

}
